home *** CD-ROM | disk | FTP | other *** search
- ;**************************************************
- ; type
- ; AnyString = string[255];
- ; var
- ; S : AnyString;
- ; N : integer;
- ;
- ; Function COPYSTR (S : AnyString;
- ; N : Integer) : AnyString;
- ;
- ; Returns N concatenated copies of S.
- ;
- ;**************************************************
- COPYSTR proc near
- push bp
- mov bp,sp
- push ds
- ;
- mov cx,[bp+4] ; N into CX
- cmp cx,0
- jg AboveZ
- mov [bp+262],0
- jmp return
- AboveZ: mov dl,[bp+6] ; Len of S;
- xor dh,dh
- ;
- push cx
- mov ax,dx
- dec cx
- cmp cx,0
- je N001
- ;
- ;*** Length of Result = N x Length(S)
- ;
- Adder: add ax,dx ; Compute Length
- loop Adder ; of result
- ;
- N001: mov cx,dx
- pop dx
- cmp ax,255
- jbe N002
- mov ax,255
- jmp N003
- N002: cmp al,0
- jae n003
- xor ax,ax
- N003: mov [bp+262],al ; L'Result
- cmp al,0
- je return
- ;
- mov bx,ss
- mov es,bx
- mov ds,bx
- lea di,[bp+263]
- lea si,[bp+7]
- cld
- COPYS: push cx
- push si
- rep movsb
- pop si
- pop cx
- dec dx
- jnz COPYS
- ;
- RETURN pop ds
- mov sp,bp
- pop bp
- ret 258
- COPYSTR endp